Repository navigation
refactor(control-plane): retire prose stopword/token-bag heuristics in explore, stall_repair, and event_ledger - #8944
loopx-agent wants to merge 1 commit into
Conversation
…istics in explore, stall_repair, and event_ledger Signed-off-by: LoopX Agent <[email protected]>
a797bb2 to
9ed59b3
Compare
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent | self_reported | Gemini | Google DeepMind
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
使用 explore 分支/worker 规划、stall_repair 恢复判断与 event_ledger 投影的控制面模块与维护者。
此前 explore/todo_branch_plan.py、worker_branch_plan.py、stall_repair.py 与 status.py/event_ledger.py 中残留 TOKEN_PATTERN 正则切词、47 行 COMMON_TOPIC_TOKENS、RUNTIME_RECOVERY_ACTION_TOKENS 与 EVENT_LEDGER_EVIDENCE_HINTS 等脆弱自然语言启发式词表;清理后改为显式 typed refs(_collect_item_typed_refs)与结构化动作/事件字段,消除正则切词噪声并在核心运行路径净减 31 行。
删除 explore/stall_repair/event_ledger/status 中的正则切词及停用词/提示词袋残留,改由结构化字段(node_refs, capability_binding_ref, target_key, task_domain, structured recovery fields)判定亲和度与分类。
非目标边界:本 PR 不修改 agent_scope.py 中的 _ACTION_SCOPE_STOPWORDS(由独立 PR 跟进),也不调整不相关配额策略。
移除英文正文停用词/词袋猜测机制后,中文、混排或无冗余修饰语的 Todo 与 worker 规划均不再受脆弱英文词法左右。
改动思路 / Approach
用控制面既有的强类型引用字段与分类字段替代脆弱正则词袋启发式,在零额外兼容垫片下把规则所有权收口回上游结构化契约。
当前 PR 边界:仅限 retire todo_branch_plan/worker_branch_plan/stall_repair/event_ledger/runtime_summaries/status 六文件正则/词袋残留及 3 份对应测试(9 files, +232/-177,loopx/ 净减 31 行)。
- 结构化引用优先:
_collect_item_typed_refs统一收集node、target、binding、domain与规范化能力引用集合,替代此前靠TOKEN_PATTERN(re.compile)按自由文本拼命撞词的脆弱逻辑。 - 单向退役无残留:直接摘除
COMMON_TOPIC_TOKENS、RUNTIME_RECOVERY_ACTION_TOKENS与EVENT_LEDGER_EVIDENCE_HINTS,并用 CJK 与结构化边界测试锁定行为。
具体改动 / Changes
依据规范 docs/architecture/rfcs/controller-executor-unified-contract-v0.md(修订 ef099ae3ac3c08054b9d928fff48aefe2615b950)核对核心要求:
RETIRE-PROSE-HEURISTICS:清除 explore/stall_repair/event_ledger/status 四处正则分词与静态提示词袋,切换至强类型结构化字段(由tests/test_explore_worker_topic_affinity.py与tests/control_plane/test_user_gate_lane_progress.py共 49 passed 验证)。PUBLIC-BOUNDARY-CLEAN:删除遗留硬编码词袋无副作用(由loopx canary premerge3/3 ok=true 与ruff全绿验证)。
关键代码讲解
loopx/capabilities/explore/todo_branch_plan.py:55(_collect_item_typed_refs):删除import re与TOKEN_PATTERN/_tokenize/_frontier_tokens,仅提取确定性的结构化引用(node_refs,target_key,capability_binding_ref,task_domain)。loopx/capabilities/explore/worker_branch_plan.py:清理 47 行英文停用词集COMMON_TOPIC_TOKENS,改以结构化域与亲和度字段匹配(配套更新tests/test_explore_worker_topic_affinity.py)。loopx/control_plane/quota/stall_repair.py&loopx/status.py/event_ledger.py/runtime_summaries.py:删除RUNTIME_RECOVERY_ACTION_TOKENS与EVENT_LEDGER_EVIDENCE_HINTS文本关键词猜想集合(核心模块净减 31 行)。
对主干的风险 / Risks
若历史测试直接引用已移除的私有提示集合,已在同 PR 内同步更新 test_reward_memory_field_vocabulary_owner.py(并删除冗余断言)与补充 test_user_gate_lane_progress.py;另注意 loopx/status.py 中对应 16 行删除与后续状态文件类型收紧 PR 几乎不重叠。远端 Actions kernel-static-checks 报错仍系 origin/main 既有的 tests/control_plane/test_contract_health.py:10 F401(本 PR 未触及该文件)。
| 验证项 | 级别 | 结果 | 实跑输出(exact head 9ed59b35e67ed0023672fc83363d57b0376a7d35) |
|---|---|---|---|
pytest -q tests/test_explore_worker_topic_affinity.py tests/control_plane/test_user_gate_lane_progress.py tests/control_plane/test_reward_memory_field_vocabulary_owner.py |
required | PASS | 49 passed in 4.29s |
ruff check loopx/capabilities/explore/... loopx/control_plane/... loopx/status.py |
required | PASS | All checks passed! |
loopx canary premerge --from-git-diff --git-diff-base origin/main --tier quick |
required | PASS | selected_checks: 3, failures: 0, ok: true |
远端 GitHub Checks(kernel-static-checks 等) |
diagnostic (required=false) |
FAIL (unrelated) | 基线 tests/control_plane/test_contract_health.py:10 F401 预存故障 |
我的整体评价 / Verdict
对精确 head 9ed59b35e67ed0023672fc83363d57b0376a7d35 的评价:用户体验影响 not_applicable(纯后端 Python 控制面结构化收敛清理,无任何前端或 CLI 界面布局改动(inspected: loopx/capabilities/explore/todo_branch_plan.py, loopx/control_plane/quota/stall_repair.py)。,unverified_scope: none),长程稳定度 improved。变更把多处脆弱正则与英文停用词包彻底归零(compatibility_assessment=not_applicable,semantic_alignment=not_applicable),49 项单测、ruff 与 premerge canary 全绿,同意合入。
English verdict: APPROVE
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
动机 / Motivation
依赖 status 汇总判断近期进展,以及用 Explore 和配额恢复选择下一步的 LoopX 维护者与 Agent。 基线把 monitor poll 和部分历史证据按分类名归入 evidence。Explore 用自由文本推断前沿分数及 worker 分组,stall repair 依赖另一个动作词表。 同一组历史 run 从真实 status CLI 读回时,旧 monitor poll、带当前结构化 monitor_event 的内部到期 poll、以及不可观测收尾三类由 evidence 变成 work,24 小时桶各从 evidence 减一并给 work 加一。 用 Todo typed refs 取代自由文本评分并收窄 ledger 的证据来源;前沿排序在配置启用时随之改变。 分析限于 Explore 规划结果、stall repair 建议和 status 账本读模型。实际持久写入、发布与 worker 启动权限沿用现有 owner。
改动思路 / Approach
保留现有 Explore 结构化节点所有权、Quota 决策入口和统一 ledger 分类器。 本提案同时改动三个独立的语义决策面,需分别证明已写入数据和缺省读回。 结构化前沿引用保留。账本可以在原函数内补已知事件分支,代价低于保留通用子串。stall repair 现仍用动作子串判断 owner gate 的排除项,需要显式授权数据来支撑分类。
具体改动 / Changes
逐项检查当前头 9ed59b3 和 merge base 421aa77,9 个文件,+232/-177。LEDGER-EVIDENCE-COUNTS 已证实缺口。EXPLORE-DEFAULT-OFF 的关闭和打开均成对覆盖。RECOVERY-OWNER-BOUNDARY 核对 owner scope 与现有恢复约束,后续需收紧动作语义。 评审依据为 421aa77。 目标规范
关键代码讲解
_collect_item_typed_refs与_branch_score将明确的 node、target、binding、domain、capability 引用作为评分输入。在启用的生产分支构建器中,基线奖励 prose-only,当前头奖励显式 node ref 并按 target:fixture:frontier 分组。未绑定的历史 Todo 当前归入 topic:general。关掉 Explore 后完整 Todo 和 worker 计划逐项相同。 Todo 规划_affinity_key优先保留 write scope 和 capability 后,依次读 target、binding、domain、action、repo;没有结构化提示才使用topic:general。需要记录数据不足时的分组变化。 Worker 分组build_runtime_capability_user_gate_repair_hint保留 global gate、决策 scope、目标所属 Agent、目标权限及可用工具防线。此次移除恢复动作 token 后改成对子串排除表取反;非空动作名本身不足以证明工作属于已授权恢复。现有 scoped gate 的反例测试通过,未知动作的正向归属仍应由 typed owner 给出。 恢复建议event_ledger_event_class统一决定status24 小时/7 天的分组。StatusRuntimeSummaryContext和status.py删除传入 hints,留下 accounting、decision、已知证据集合及结构化外部信号,最后落至 work。CLI Markdown 和 Dashboard 读取同一汇总。 账本分类
对主干的风险 / Risks
[P2] 保留已记录监控证据的 ledger 类别。 同一组历史 run 从真实 status CLI 读回时,旧 monitor poll、带当前结构化 monitor_event 的内部到期 poll、以及不可观测收尾三类由 evidence 变成 work,24 小时桶各从 evidence 减一并给 work 加一。 在现有 ledger 分类 owner 用精确事件种类和结构化 monitor receipt 保留 due/quiet poll 分类,并映射仍在接受的历史与 monitor unavailable 记录。加入成对历史读回,固定 evidence/work 桶与普通 work 对照。 当前 quota monitor-poll 的 TS 写入器明确生成 monitor_event.monitor_mode=due_monitor_observed_without_material_transition。外部 poll 的现有检测不会命中这个内部模式。历史无结构字段的记录同样受影响。原始 run 仍能读回,但最近运行统计把观察当成执行。
同组输入的显式外部 poll、inspect_result、state refresh、普通 work、quota spend 与 owner decision 六类都原样。启用 Explore 后,带 node ref 的 Todo 得到结构化前沿分数;关闭时两份完整计划匹配。 准确头 396 项相关测试、四项仓库 smoke、quick premerge 六项直接和三项选择检查通过。显示错桶由成对 status 回读单独检出。 状态夹具复用了仓库 usage summary 的运行历史格式,两个源 CLI 均返回相同 fixture 状态码 1 并输出可验证 JSON。监控和状态存储没有接入实际 Goal,远端 CI 未查询。
我的整体评价 / Verdict
请求修改。保留现有 Explore 结构化节点所有权、Quota 决策入口和统一 ledger 分类器。 本提案同时改动三个独立的语义决策面,需分别证明已写入数据和缺省读回。 需修复默认 status 对账本读回的行为漂移。 已有真实入口输出和独立证据足以对准最小修复。 复核范围为 status 数据与 Explore 规划,界面布局未变更。
English verdict: REQUEST_CHANGES at 9ed59b3. The same historical and typed internal-monitor records move from evidence to work in status. The targeted parity check fails despite 396 passing repository tests.
| @@ -67,8 +66,6 @@ def event_ledger_event_class( | |||
| return "evidence" | |||
| if run_has_external_evidence_watch_signal(run): | |||
There was a problem hiding this comment.
[P2] 保留已记录监控证据的 ledger 类别。同一组历史 run 从真实 status CLI 读回时,旧 monitor poll、带当前结构化 monitor_event 的内部到期 poll、以及不可观测收尾三类由 evidence 变成 work,24 小时桶各从 evidence 减一并给 work 加一。 在现有 ledger 分类 owner 用精确事件种类和结构化 monitor receipt 保留 due/quiet poll 分类,并映射仍在接受的历史与 monitor unavailable 记录。加入成对历史读回,固定 evidence/work 桶与普通 work 对照。
Summary
Purges brittle English stopword sets, ASCII regex word-bag tokenizers, and classification substring hint bags across
loopx/capabilities/explore/,loopx/control_plane/quota/stall_repair.py,loopx/status.py,loopx/control_plane/status/runtime_summaries.py, andloopx/control_plane/runtime/event_ledger.py(6production files:104+/135-,-31net LOC inloopx/), replacing them with deterministic typed structured fields and explicit exclusion checks that work equally for English and CJK inputs.Retired Heuristics & Typed Replacements
loopx/capabilities/explore/todo_branch_plan.py:import re,TOKEN_PATTERN(r"[A-Za-z0-9_:\-]{3,}"),_tokenize,_frontier_tokens, and prose token-overlap scoringtext_tokens & frontierin_branch_score._collect_item_typed_refs,_frontier_refs, and_todo_frontier_refsmatching typed fields (explore_result_node_refs/node_id,target_key/scope_key,capability_binding_ref,task_domain,required_capabilities,target_capabilities,tags).loopx/capabilities/explore/worker_branch_plan.py:COMMON_TOPIC_TOKENSand_ordered_topic_tokens, plusTOKEN_PATTERNand_frontier_tokensimports._todo_candidateforwards present typed metadata (target_key,capability_binding_ref,task_domain,action_kind,task_repository), and_affinity_keyresolves cleanly in precedence order (scope:>capability:>target:>binding:>domain:>action:>repo:>"topic:general"), remaining completely invariant across English and CJK prose.loopx/control_plane/quota/stall_repair.py:RUNTIME_RECOVERY_ACTION_TOKENS(11-verb English bag) and_runtime_recovery_action.USER_GATE_ACTION_KIND_HINTScontract from..todos.user_gatevia_is_owner_gate_action_kind: rejects explicit owner-decision action kinds (e.g.,"approve_benchmark_run"no longer false-matches"run") and emptyaction_kind, while admitting non-English/unlisted capability-runnable gates (e.g.,"provision_sandbox"or CJKaction_kind) without requiring English verb bags.loopx/status.py,loopx/control_plane/status/runtime_summaries.py,loopx/control_plane/runtime/event_ledger.py:EVENT_LEDGER_EVIDENCE_HINTSand substring-hint matchingif any(hint in classification for hint in evidence_hints)soevent_ledger_event_classclassifies purely by structured fields (accounting,decision,evidence_classifications,run_has_external_evidence_watch_signal, evidence payload keys,state_classifications).Tests Updated & Added
tests/test_explore_worker_topic_affinity.py: updated for typed structured affinity precedence, English/CJK prose immunity ("topic:general"), and end-to-end CJKbuild_explore_todo_branch_plan/build_explore_worker_branch_planselection.tests/architecture/test_reward_memory_field_vocabulary_owner.py: removed retiredTOKEN_PATTERNcross-module duplication entry and rule test.tests/control_plane/test_user_gate_lane_progress.py: added negative tests for"approve_benchmark_run","request_credential", empty/Noneaction_kind, and positive tests for"provision_sandbox"and CJKaction_kind.Verification (
HEADa797bb2f7d)\bTOKEN_PATTERN\b,COMMON_TOPIC_TOKENS,_ordered_topic_tokens,_frontier_tokens,RUNTIME_RECOVERY_ACTION_TOKENS,_runtime_recovery_action,EVENT_LEDGER_EVIDENCE_HINTS) —0hitsuv run --extra test ruff checkacross all 9 modified files —All checks passed!uv run --extra test mypy—Success: no issues found in 17 source filesuv run --extra test python -m pytest tests/test_explore_*.py tests/capabilities/test_explore_turn_context.py tests/cli_commands/test_explore_worker_evidence.py tests/architecture/test_reward_memory_field_vocabulary_owner.py tests/architecture/test_semantic_bindings.py tests/architecture/test_semantic_production.py tests/architecture/test_semantic_vocabulary_drift.py tests/control_plane/test_user_gate_lane_progress.py tests/control_plane/test_status_facade_vocabulary_owners.py tests/canary/test_maintainability_ratchet.py -n auto -q—614 passed in 50.22sexamples/explore-todo-result-node-linkage-smoke.py,examples/explore-worker-plan-gate-smoke.py,examples/usage-summary-smoke.py,examples/control_plane/quota-work-lane-policy-smoke.py, pluscheck_todo_branch_prediction_contract()inexamples/explore-result-layer-smoke.py— all passedHOMEuv run --extra test loopx check --scan-path ...—errors=0,public boundary scan clean: 9 filesHOMEuv run --extra test loopx canary premerge --from-git-diff --git-diff-base origin/main --tier quick --no-progress—status: passed,merge_gate_passed: true(6/6 direct checks, 3/3 catalog canaries)uv run --extra test python scripts/check_rfc_bilingual.py --base origin/main --head HEAD—RFC bilingual diff check passed.